package com.example.task01_servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "CookieServlet2", value = "/cookie2")
public class CookieServlet2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.获取客户端发来的Cookie信息并打印出来
        Cookie[] cookies = request.getCookies();
        System.out.println("获取到的Cookie信息有:");
        for(Cookie tc:cookies){
            System.out.println(tc.getName()+"对应的值为:"+tc.getValue());
        }
    }
}
